const fs = require('fs')

// 读取本地配置文件
let config = {
  mongodb: 'mongodb://127.0.0.1/company',
  listen: {
    address: '0.0.0.0',
    port: 4399,
  },
}

try {
  const localConfig = JSON.parse(fs.readFileSync('config/config.json', 'utf-8'))
  // 删除空配置项
  Object.keys(localConfig).forEach((item) => {
    if (!localConfig[item]) {
      delete localConfig[item]
    }
  })
  Object.assign(config, localConfig)
} catch (e) {
  console.error(e)
}

module.exports = config
